﻿using Caiji.OpCommand;
using Caiji.UserControls;
using Caiji.ViewModels;
using Caiji.Views;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Caiji
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        MainWindowModel main = new MainWindowModel();
        public MainWindow()
        {
            InitializeComponent();
           
            this.DataContext = main;
        }
        //显示车间详情页
        void ShowUI()
        {
             CheDetail cheDetail = new CheDetail();
            main.uc = cheDetail;
            //动画效果(由下而上)
            ThicknessAnimation thicknessAnimation = new ThicknessAnimation(
                new Thickness(0,50,0,-50), //初始位置
                new Thickness(0,0,0,0), //结束位置
                new TimeSpan(0,0,0,0,1000) //时间
                );
            //透明度
            DoubleAnimation doubleAnimation = new DoubleAnimation(
                0, //初始透明度
                1, //结束透明度
                new TimeSpan(0, 0, 0, 0, 1000)); //时间
            //设置动画
            Storyboard.SetTarget(thicknessAnimation, cheDetail);
            Storyboard.SetTarget(doubleAnimation, cheDetail);
            //设置属性
            Storyboard.SetTargetProperty(thicknessAnimation,new PropertyPath("Margin"));
            Storyboard.SetTargetProperty(doubleAnimation, new PropertyPath("Opacity"));
            Storyboard storyboard = new Storyboard();
            storyboard.Children.Add(thicknessAnimation);
            storyboard.Children.Add(doubleAnimation);
            storyboard.Begin();
        }
        public Commands ShowData { get { return new Commands(ShowUI); } }
        public Commands MainUI { get { return new Commands(MainPage); } }

        private void MainPage()
        {
            main.uc = new UC();
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            this.WindowState = WindowState.Minimized;
        }

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            this.WindowState = WindowState.Maximized;
        }

        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            //this.Close(); //关闭窗口
           Environment.Exit(0); //关闭 程序。整个应用程序都退出
        }
        void ShowSetting()
        {
            //Owner 将窗体的父亲 设置为 this
            var s = new Setting() {Owner = this};
            s.ShowDialog();
        }
        public Commands ShowSettingCmd
        {
            get { return new Commands(ShowSetting);
        }}
    }
}